package service.serviceimpl;

import dao.AddressDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.Address;
import service.AddressService;

import java.util.List;
@Service
public class AddressServiceimpl implements AddressService {


    @Autowired
    AddressDao addressDao;
    @Override
    public List<Address> selectAll(int userId) {
        List<Address> list = addressDao.selectAll(userId);
        return list;

    }

    @Override
    public void deleteAddress(int id) {
        addressDao.deleteAddress(id);
    }

    @Override
    public void updateAddress(Address address) {
        addressDao.updateAddress(address);
    }

    @Override
    public void defaultAddress(int id, int userId) {
        addressDao.setDefault(userId);

        addressDao.setNewDefault(id,userId);
    }

    @Override
    public void addAddress(Address address) {
        addressDao.addAddress(address);
    }
}
